package com.trolls.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.IsSerializable;

public class Troll extends Item implements IsSerializable  {
	
	public Troll(){
		
	}
	
	public Troll(int id) {
		super(id);
	}

	public Troll(int id, String name, Race race, String description,
			String image, int ptsAttaque, int ptsDegat, int ptsEsquive,
			int ptsRegeneration, int ptsPv, int ptsCompetenceSpecial,
			int ptsCompetenceSpecialSecondaire) {
		super(id, name, description, image);
		this.race = race;
		this.ptsAttaque = ptsAttaque;
		this.ptsDegat = ptsDegat;
		this.ptsEsquive = ptsEsquive;
		this.ptsRegeneration = ptsRegeneration;
		this.ptsPv = ptsPv;
		this.ptsCompetenceSpecial = ptsCompetenceSpecial;
		this.ptsCompetenceSpecialSecondaire = ptsCompetenceSpecialSecondaire;
	}


	private Race race;
	private int ptsAttaque;
	private int ptsDegat;
	private int ptsEsquive;
	private int ptsRegeneration;
	private int ptsPv;
	private int ptsCompetenceSpecial;
	private int ptsCompetenceSpecialSecondaire;
	
	
	//public save(){}
	
	//Getters and Setters

	
	
	public Race getRace() {
		return race;
	}
	public void setRace(Race race) {
		this.race = race;
	}
	
	public int getPtsAttaque() {
		return ptsAttaque;
	}
	public void setPtsAttaque(int ptsAttaque) {
		this.ptsAttaque = ptsAttaque;
	}
	public int getPtsDegat() {
		return ptsDegat;
	}
	public void setPtsDegat(int ptsDegat) {
		this.ptsDegat = ptsDegat;
	}
	public int getPtsEsquive() {
		return ptsEsquive;
	}
	public void setPtsEsquive(int ptsEsquive) {
		this.ptsEsquive = ptsEsquive;
	}
	public int getPtsRegeneration() {
		return ptsRegeneration;
	}
	public void setPtsRegeneration(int ptsRegeneration) {
		this.ptsRegeneration = ptsRegeneration;
	}
	public int getPtsPv() {
		return ptsPv;
	}
	public void setPtsPv(int ptsPv) {
		this.ptsPv = ptsPv;
	}
	public int getPtsCompetenceSpecial() {
		return ptsCompetenceSpecial;
	}
	public void setPtsCompetenceSpecial(int ptsCompetenceSpecial) {
		this.ptsCompetenceSpecial = ptsCompetenceSpecial;
	}
	public int getPtsCompetenceSpecialSecondaire() {
		return ptsCompetenceSpecialSecondaire;
	}
	public void setPtsCompetenceSpecialSecondaire(
			int ptsCompetenceSpecialSecondaire) {
		this.ptsCompetenceSpecialSecondaire = ptsCompetenceSpecialSecondaire;
	}

	@Override
	public String toString() {
		return super.toString()+", Troll [race=" + race + ", ptsAttaque=" + ptsAttaque
				+ ", ptsDegat=" + ptsDegat + ", ptsEsquive=" + ptsEsquive
				+ ", ptsRegeneration=" + ptsRegeneration + ", ptsPv=" + ptsPv
				+ ", ptsCompetenceSpecial=" + ptsCompetenceSpecial
				+ ", ptsCompetenceSpecialSecondaire="
				+ ptsCompetenceSpecialSecondaire + "]";
	}
	
	public String getImagePath() {
		return GWT.getHostPageBaseURL()
				+ "images/Troll/" +image;
	}
	public void afficherItem( Content c ){
		c.showItem(this);
	}
	public void afficher( Content c ){
		c.showTroll((Troll)this);
	}

	public void save() {
		LaTerreDesTrolls.get().getMyServiceTroll().saveTroll(this, LaTerreDesTrolls.get().getSaveTrollcallback());
		// TODO Auto-generated method stub
	}

	public void delete() {
		// TODO Auto-generated method stub
		LaTerreDesTrolls.get().getMyServiceTroll().removeTroll(this, LaTerreDesTrolls.get().getRemoveTrollcallback());
	}

	public String AfficherCaracteristiques() {
		return "Race : "+getRace().getName()+"<br/>"
	+"Attaque : "+ptsAttaque+"<br/>"
	+"Dégats : "+ptsDegat+"<br/>"
	+"Esquive: "+ptsEsquive+"<br/>"
	+"Regeneration: "+ptsRegeneration+"<br/>"
	+"Pointsde vie: "+ptsPv+"<br/>"
	+this.race.getCompetenceSpeciale()+": "+ptsCompetenceSpecialSecondaire+"<br/>"
	+this.race.getCompetenceSpecialeSecondaire()+": "+ptsCompetenceSpecialSecondaire+"<br/>";
	}
	
	public static String[] getAttributsName(){
		String [] attributs = new String [7];
		attributs[0] = "Nom";
		attributs[1] = "Race";
		attributs[2] = "Pts d'attaque";
		attributs[3] = "Pts de dégat";
		attributs[4] = "Pts d'esquive";
		attributs[5] = "Pts de Régéneration";
		attributs[6] = "Pts de vie";	
		return attributs;

	}
	public String[] getAttributs(){
		String [] attributs = new String [7];
		attributs[0] = this.getName();
		attributs[1] = this.getRace().getName();
		attributs[2] = String.valueOf(this.getPtsAttaque());
		attributs[3] = String.valueOf(this.getPtsDegat());
		attributs[4] = String.valueOf(this.getPtsEsquive());
		attributs[5] = String.valueOf(this.getPtsRegeneration());
		attributs[6] = String.valueOf(this.getPtsPv());	
		return attributs;

	}

}
